/* Pointer  as function arguments */

#include<stdio.h>

	void swapping(int c, int d) 
	{
	  int tmp;
	  tmp = c;
	  c = d;
	  d = tmp;
     printf("Swapping function called.\n");
	  printf("Swapping function - printing c %d  and d %d\n", c , d);
	}


  void swapping2(int *ptr_e, int *ptr_f)
      {
      int tmp;
      tmp = *ptr_e;
      *ptr_e = *ptr_f;
      *ptr_f = tmp;
           printf("Swapping2 function called.\n");
          printf("Swapping function - printing c %d  and d %d\n", *ptr_e , *ptr_f);
    }



	int main(void) {
       /* Wrong way*/
      int a,b;
      a=5;
      b=10;
	  printf("\n\nMain input to swapping function: c is %d and d %d\n", a, b);
	  swapping(a,b);
	  printf("Regular main output: a is %d and b is %d\n", a, b);

       /* Right way */ 
        int x,y;
        x=5;
        y=10;

        printf("\n\nMain input to swapping2 function: ptr_e is %d and ptr_f  %d\n", x, y);
        swapping2(&x,&y);
        printf("Regular main output values are now swapped: a is %d and b is %d\n", x, y);
       
        return 0;

   }

    


	
